In MVC, we have the JsonResultclass by which we can return back data in JSON format. Below is a simple sample code which returns back a Customer object in JSON format using JsonResult.
public JsonResult getCustomer() { Customer obj = new Customer(); obj.CustomerCode = "1001"; obj.CustomerName = "Shiv"; return Json(obj,JsonRequestBehavior.AllowGet); }
Liked By
Write Answer
How to send result back in JSON format in MVC
Join MindStick Community
You have need login or register for voting of answers or question.
Niraj Kumar Mishra
28-Aug-2017In MVC, we have the JsonResult class by which we can return back data in JSON format. Below is a simple sample code which returns back a Customer object in JSON format using JsonResult.